<template>
  <transition name="modal">
    <div class="modal">
      <div class="modal-head">
        <p class="modal-name">{{ title }}</p>
        <span class="iconfont icon-guanbi" @click="close"></span>
      </div>
      <div class="modal-main">
        <slot></slot>
      </div>
    </div>
  </transition>
</template>

<script setup>
import { defineProps, ref, defineEmits } from 'vue'
import { useNewCardStore } from "@/store/newCard.js"

const props = defineProps({
  title: {
    type: String,
    default: '标题',
  },
})

const store = useNewCardStore()

const emits = defineEmits(['close'])

// 关闭弹出层
function close() {
  store.clearUrl()
  emits('close', false)
}
</script>

<style lang="less" scoped>
.modal {
  &-enter {
    &-from {
      transform: translateX(360px);
    }
    &-active {
      transition: 0.3s;
    }
    &-to {
      transform: translateX(0px);
    }
  }
  &-leave {
    &-from {
      transform: translateX(0px);
    }
    &-active {
      transition: 0.3s;
    }
    &-to {
      transform: translateX(360px);
    }
  }
}

.modal {
  width: 360px;
  height: calc(100vh - 53px);
  z-index: 10;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px);
  position: fixed;
  right: 0;
  top: 53px;
  
  .modal-head {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: @padding-20;
    box-sizing: border-box;
    .modal-name {
      font-size: 16px;
      color: @gray-1;
      font-weight: 600;
    }
    .icon-guanbi {
      cursor: pointer;
      color: @gray-2;
    }
  }

  .modal-main {
    height: calc(100% - 64px);
    box-sizing: border-box;
    overflow: auto;
    padding-bottom: 80px;

    // 自定义滚动条样式
    &::-webkit-scrollbar {
      width: 4px;
    }
    &::-webkit-scrollbar-thumb {
      background-color: #c1c1c1;
      border-radius: 3px;
    }

    &::-webkit-scrollbar-track {
      background-color: #f1f1f1;
    }

  }


}
</style>
